<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function median(...nums) {
        return nums.sort()[Math.floor(nums.length / 2)];
    }

    const proxy = new Proxy(median, {
        apply(target, thisArg, argumentsList) {
            for (const arg of argumentsList) {
                if (typeof arg !== 'number') {
                    throw 'Non-number argument provided';
                }
            }
            return Reflect.apply(...arguments);
        }
    });

    console.log(proxy(4, 7, 1)); // 4 
    console.log(proxy(4, '7', 1));
    // Error: Non-number argument provided
    
    // 类似的,构造函数也一样
    
</script>
</body>
</html>